package zjut.cocouml.part;

import java.beans.PropertyChangeEvent;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

import zjut.cocouml.editpolicy.AppDeletePolicy;
import zjut.cocouml.editpolicy.ModifyAttributePolicy;
import zjut.cocouml.editpolicy.ModifyMethodPolicy;
import zjut.cocouml.figure.BAttributeFigure;
import zjut.cocouml.figure.BMethodFigure;
import zjut.cocouml.model.BAttribute;
import zjut.cocouml.model.BMethod;
import zjut.cocouml.model.BaseElement;

public class BMethodPart extends AppAbstractEditPart{

	protected IFigure createFigure() {
		BMethodFigure figure = new BMethodFigure();
		return figure;
	}

	protected void createEditPolicies() {
		installEditPolicy(EditPolicy.NODE_ROLE,new AppDeletePolicy());
		installEditPolicy(EditPolicy.COMPONENT_ROLE, new ModifyMethodPolicy());
	}
	protected void refreshVisuals() {
		BMethodFigure figure = (BMethodFigure)getFigure();
		BMethod model = (BMethod)getModel();
		
		figure.setLabelName(model.getDisplayName());
	}

	public void propertyChange(PropertyChangeEvent evt) {
		if (evt.getPropertyName().equals(BaseElement.PROPERTY_RENAME)) {
			System.out.println("-------------BAttributePart----REMOVE--------------");
			this.refreshVisuals();
		}
	}

}
